package com.abaddon.controller;

import com.abaddon.model.TagManager;
import com.abaddon.view.Abaddon;

import android.graphics.Color;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;

public class AbaddonLocationListener implements LocationListener {
	
	private	Abaddon abaddon;
	private	int latitude;
	private int longitude;

	public AbaddonLocationListener(Abaddon abaddon) {
		this.abaddon = abaddon;
	}
	
	@Override
	public void onLocationChanged(Location location) {
		latitude = (int)(location.getLatitude()*Math.pow(10, 6));
		longitude = (int)(location.getLongitude()*Math.pow(10, 6));

		TagManager.updatePerson(TagManager.getUserName(), latitude, longitude);
		
		this.abaddon.setTitle("Latitude: " + latitude + " Longitude: " + longitude);
		abaddon.setTitleColor(Color.rgb((int)(Math.random()*255), (int)(Math.random()*255), (int)(Math.random()*255)));
	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) { }
	
	@Override
	public void onProviderDisabled(String provider) { }

	@Override
	public void onProviderEnabled(String provider) { }

}
